<?php
/**
 * Created by PhpStorm.
 * User: zhou
 * Date: 2019/4/14
 * Time: 下午4:30
 */

namespace App\Models;


use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class Mac extends Model
{
    protected $table = 'mac';

    /**
     * 未绑定的设备mac号
     */
    public static function unbind_list()
    {
        $list = self::query()
            -> select('mac.mac','mch.mac AS binded_mac')
            -> leftJoin('machine AS mch','mch.mac','=','mac.mac')
            -> get()
            -> toArray();
        $data = [];
        foreach($list as $v){
            if($v['binded_mac'] == $v['mac']){
                continue;
            }
            $data[] = $v;
        }
        return $data;
    }
}